import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    // 代理
    proxy: {
      // 真正和后端交互的时候 用的
      '/abc': {
        target: 'http://localhost:9999/',
        // path http://localhost:3000/api/login
        rewrite: path => path.replace(/^\/abc/, ''),
        changeOrigin: true,
      },
      // 本地mock的时候用
      '/mock': {
        target: 'https://dev.usemock.com/66e2646f813b0ff9cfbefbad/',
        rewrite: path => path.replace(/^\/mock/, ''),
        changeOrigin: true,
      }
    },
  }
})
